<template>
  <view class="chat-container">
    <!-- 导航栏 -->
    <view class="navbar">
      <view class="statusBar" :style="{ height: getStatusBarHeight() + 'px' }"></view>
      <view class="titleBar" :style="{ height: getTitleBarHeight() + 'px' }">
        <view class="title">
          智能工具
        </view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content">
      <!-- 创意灵感区域 -->
      <view class="creative-inspiration" :class="{ 'animate-inspiration': isMounted }">
        <text class="inspiration-text">{{ visibleInspirationText }}</text>
        <text class="inspiration-greeting">{{ visibleInspirationGreeting }}</text>
      </view>

      <!-- 底部功能区域 -->
      <view class="bottom-functions">
        <view
          v-for="(button, index) in bottomFunctions"
          :key="index"
          class="bottom-function"
          :class="{ 'animate-bottom-function': isMounted }"
          @click="button.action"
          :style="{ animationDelay: `${1000 + index * 200}ms` }"
        >
          <text class="function-icon">{{ button.icon }}</text>
          <text class="function-text">{{ button.text }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { getStatusBarHeight, getTitleBarHeight } from "@/utils/system.js";

const isMounted = ref(false);
const visibleInspirationText = ref('');
const visibleInspirationGreeting = ref('');

const fullInspirationText = 'Creative Inspiration';
const fullInspirationGreeting = '智能工具，为您打造个性化体验';

const code = () => {
  uni.navigateTo({
    url: "/pages/tool/code/code",
  });
};

const drawing = () => {
  uni.navigateTo({
    url: "/pages/tool/picture/drawing",
  });
};

const video = () => {
  uni.navigateTo({
    url: "/pages/tool/video/video",
  });
};

const imageProcessing = () => {
  uni.navigateTo({
    url: "/pages/tool/imageProcesse/imageProcesse"
  })
}

const file = ()=>{
	uni.navigateTo({
		url:"/pages/tool/file/FileProcesse"
	})
}

const bottomFunctions = ref([
  { icon: '🖌️', text: '绘画图片', action: drawing },
  { icon: '🎥', text: '视频生成', action: video },
  { icon: '📱', text: '二维码', action: code },
  { icon: '🖼️', text: '图片处理', action: imageProcessing }
  // { icon: '📂', text: '文件处理', action: file }
]);

onMounted(() => {
  isMounted.value = true;

  // 字符逐个显示的动画
  let index = 0;
  const textInterval = setInterval(() => {
    if (index < fullInspirationText.length) {
      visibleInspirationText.value = fullInspirationText.substring(0, index + 1);
      index++;
    } else {
      clearInterval(textInterval);
      index = 0;
      const greetingInterval = setInterval(() => {
        if (index < fullInspirationGreeting.length) {
          visibleInspirationGreeting.value = fullInspirationGreeting.substring(0, index + 1);
          index++;
        } else {
          clearInterval(greetingInterval);
        }
      }, 100);
    }
  }, 100);
});
</script>

<style scoped>
.chat-container {
  font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  background-color: #ffffff;
  color: #333;
  display: flex;
  flex-direction: column;
  max-width: 400px;
  margin: 0 auto;
  overflow: hidden;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  background-color: #ffffff;
  pointer-events: none;
}

.titleBar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 30rpx;
}

.title {
  color: #333333;
  font-size: 36rpx;
  font-weight: 700;
  letter-spacing: 2rpx;
  line-height: 1.5;
}

.content {
  flex: 1;
  margin-top: 70px;
  padding: 0 15rpx; /* 调整左右边距 */
}

.creative-inspiration {
  margin-top: 10px;
  background-color: #1a1a1a;
  padding: 20px;
  margin-left: 5rpx; /* 减小左右边距 */
  margin-right: 5rpx; /* 减小左右边距 */
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  transform: scale(0.8);
  opacity: 0;
  transition: transform 1.5s ease, opacity 1s ease;
}

.animate-inspiration {
  transform: scale(1);
  opacity: 1;
}

.inspiration-text {
  font-size: 16px;
  color: #ccc;
  margin: 0;
}

.inspiration-greeting {
  font-size: 18px;
  color: #4CAF50;
  margin: 0;
  font-weight: bold;
}

.bottom-functions {
  display: flex;
  flex-wrap: wrap; /* 添加换行功能 */
  justify-content: space-between;
  padding: 15px;
  background-color: #f8f8f8;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  margin-top: 20px;
}

.bottom-function {
  position: relative;
  height: 80px;
  width: calc(33.333% - 15px); /* 减小盒子宽度 */
  margin: 0 7px 10px; /* 添加下边距 */
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  transform: translateY(20px);
  opacity: 0;
}

.animate-bottom-function {
  opacity: 1;
  transform: translateY(0);
}

.bottom-function:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.bottom-function:active {
  transform: scale(0.95);
}

.function-icon {
  font-size: 24px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5e9aff 0%, #7b68ee 100%);
  color: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.function-text {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  text-align: center;
  margin-top: 5px;
  line-height: 1.3;
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}
</style>